var User = require('../../app/controller/admin/user');

var Mp3 = require('../../app/controller/admin/mp3');

var Blog=require('../../app/controller/admin/blog')

module.exports = function(app) {

    app.use(function(req, res, next) {
        var _user = req.session.user;
        app.locals.user = _user;
        app.locals.title='Musik';
        next();

    });

    //管理员
    app.get('/admin', User.signinRequired, User.adminRequired, User.admin);
    app.get('/admin/mp3', User.signinRequired, User.adminRequired, Mp3.fetch);

    app.post('/admin/mp3', User.signinRequired, User.adminRequired,Mp3.save);

    app.get('/admin/mp3/del',User.signinRequired, User.adminRequired,Mp3.del);
    app.get('/admin/user', User.signinRequired, User.adminRequired, User.fetch);

    //文章列表
    app.get('/admin/blog',User.signinRequired, User.adminRequired,Blog.fetch)
    app.post('/admin/blog',User.signinRequired, User.adminRequired,Blog.save)
    app.post('/admin/update',User.signinRequired, User.adminRequired,Blog.update)
    app.get('/admin/blog/edit/:id',User.signinRequired, User.adminRequired,Blog.edit)

    //用户设置
    app.get('/admin/profile',User.profile)


    /**
     * MV管理页
     */
    app.get('/admin/video', function(req, res) {
        res.render('admin/video');
    });

}
